class Solution {
public:
    int findMin(vector<int>& nums) {
        int l=-1, r=nums.size()-1, mid=0;
        while(l+1<r) //(l,r]
        {
            mid=(l+r)>>1;
            /* if(nums[mid]==nums[r]) r--; //如果有重复值
            else */if(nums[mid]<nums[r]) r=mid;
            else l=mid;
        }
        return nums[r];
    }
};

class Solution {
public:
    int findMin(vector<int>& nums) {
        int l=0, r=nums.size()-1; //[l, r]
        while(l<r) {
            int mid=(l+r)>>1;
            if(nums[mid]<nums[r]) r=mid;
            else l=mid+1;
        }
        return nums[l];
    }
};